package com.oa.ylms.apps.dao.limit.impl;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oa.ylms.apps.dao.limit.IPostLimitDao;
import com.oa.ylms.apps.entity.limit.PostLimitValue;

public class PostLimitDaoImpl extends HibernateDaoSupport implements
		IPostLimitDao {

	@Override
	public boolean addOrModifyPostLimit(PostLimitValue postLimit) throws Exception {
		if(postLimit != null){
			try{
				this.getHibernateTemplate().saveOrUpdate(postLimit);
			}catch(Exception e){
				e.printStackTrace();
				return false;
			}
			return true;
		}
		return false;
	}

	@Override
	public boolean deletePostLimit(PostLimitValue postLimit) throws Exception {
		if(postLimit != null){
			try{
				this.getHibernateTemplate().delete(postLimit);
			}catch(Exception e){
				return false;
			}
			return true;
		}
		return false;
	}

	@Override
	public PostLimitValue queryByPostId(PostLimitValue postLimit) throws Exception {
		if(postLimit != null){
			return (PostLimitValue) this.getHibernateTemplate().get(PostLimitValue.class, postLimit.getPostId());
		}
		return null;
	}

}
